package com.xlhl.init.controller;

import com.xlhl.init.common.Result;
import com.xlhl.init.model.vo.PermissionVO;
import com.xlhl.init.service.PermissionService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author xlhl
 */
@RestController
@RequestMapping("/permission")
public class PermissionController {

    @Resource
    private PermissionService permissionService;


    /**
     * 根据 角色ID 获取对应的 权限列表
     *
     * @param roleId
     * @return
     */
    @GetMapping("/list/{roleId}")
    public Result<List<PermissionVO>> listPermissionByRoleId(@PathVariable("roleId") Long roleId) {
        return Result.success(permissionService.listByRoleId(roleId));
    }

    /**
     * 获取对应的 权限列表
     *
     * @return
     */
    @GetMapping("/list")
    public Result<List<PermissionVO>> listPermission() {
        return Result.success(permissionService.listPermission());
    }
}






















